function $(name)
{
  return document.getElementById(name);
}

function range(min,max,value)
{
  return value >= min && value <= max;
}

Function.prototype.inherit = function (superClass)
{   
  for(var i in superClass.prototype)
    this.prototype[i] = superClass.prototype[i];
  
  this.prototype.constructor = this;
  
  if(this.prototype['getParents'] == null)
    this.prototype['getParents'] = function () {return [superClass];};
  else {
    var parents = this.prototype['getParents']();
    parents.push(superClass);
    this.prototype['getParents'] = function () {return parents;};
  }    
}

function instanceOf(object,type)
{
  if(object.__proto__.constructor == type)
    return true;
  
  if(object.getParents == null)
    return false;
  
  var parents = object.getParents();
  for(var i in parents)
    if(parents[i] == type)
      return true;
      
  return false;
}

function floor(val)
{
  return Math.floor(val);
}

function ceil(val)
{
  return Math.ceil(val);
}
